package com.itheima.fanxing;

import com.itheima.domain.Student;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

/*
自定义泛型方法
 */
public class Demo04 {
    public static void main(String[] args) {
        String[] arr = {"坤坤", "签签", "小鹿", "滔滔"};
        //ArrayList<String> list = arrayToList(arr);
        ArrayList<String> list = new ArrayList<>();
        System.out.println(list);
        Student[] stus = {new Student("坤坤1", 26), new Student("坤坤2", 26), new Student("坤坤3", 26)};
        ArrayList<Student> list1 = arrayToList(stus);
        Collections.addAll(list,arr);
       System.out.println(list);

    }

    //数组 转集合
    public static <T> ArrayList<T> arrayToList(T[] arr) {
        ArrayList<T> list = new ArrayList<>();
        for (T t : arr) {
            list.add(t);
        }
        return list;
    }
}

